/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package org.kz.shange.daosMongo;

import org.kz.shange.models.Author;
import org.kz.shange.models.IAuthorDao;
import org.springframework.data.mongodb.core.MongoOperations;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;

/**
 *
 * @author Administrator
 */
public class AuthorDaoImpl implements IAuthorDao {

    private MongoOperations daoTemplate;

    @Override
    public void saveAuthor(Author a) {
        daoTemplate.save(a);
    }

    @Override
    public Author findAuthor(String account) {
        return daoTemplate.findOne(new Query(Criteria.where("account").is(account)), Author.class);
    }

    @Override
    public Author findAuthorById(String uid) {
        return daoTemplate.findById(uid, Author.class);
    }

    public MongoOperations getDaoTemplate() {
        return daoTemplate;
    }

    public void setDaoTemplate(MongoOperations daoTemplate) {
        this.daoTemplate = daoTemplate;
    }

}
